cc.Class({
    extends: cc.Component,

    properties: {
       tapMine: cc.Node,
       tapToday: cc.Node,
       panelMine: cc.Node,
       panelToday: cc.Node,

        lb_tsuport: cc.Label,
        lb_trank: cc.Label,
        lb_tbrank: cc.Label,
        lb_tbname: cc.Label,
        lb_tbsuport: cc.Label,
        lb_tbreward: cc.Label,
        lb_tbtips: cc.Label,

        lb_mdate: cc.Label,
        lb_mrank: cc.Label,
        lb_msuport: cc.Label,
        lb_mreward: cc.Label,

    },

    onLoad () {
        this.panelMine.parent = null;
        this.panelToday.parent = null;
        this.tapMine.on('toggle', this.onToggle, this);
        this.tapToday.on('toggle', this.onToggle, this);
        this.currPanel = cc.instantiate(this.panelToday);
        this.currPanel.parent = this.node;

        this.initWords();
    },

    initWords: function(){
        this.lb_tsuport.string = LangLocal.word10;
        this.lb_trank.string = LangLocal.word11;
        this.lb_tbrank.string = LangLocal.word12;
        this.lb_tbname.string = LangLocal.word13;
        this.lb_tbsuport.string = LangLocal.word14;
        this.lb_tbreward.string = LangLocal.word15;
        this.lb_tbtips.string = LangLocal.word16;

        this.lb_mdate.string = LangLocal.word17;
        this.lb_mrank.string = LangLocal.word12;
        this.lb_msuport.string = LangLocal.word14;
        this.lb_mreward.string = LangLocal.word18;

    },
    onToggle(evt) {
        if(this.currPanel) this.currPanel.parent = null;
        if(evt.target == this.tapMine) this.currPanel = cc.instantiate(this.panelMine);
        else this.currPanel = cc.instantiate(this.panelToday);
        this.currPanel.parent = this.node;
    },

    updatePanel() {
        if(this.currPanel) this.currPanel.parent = null;
        if(this.tapMine.getComponent(cc.Toggle).isChecked) this.currPanel = cc.instantiate(this.panelMine);
        else this.currPanel = cc.instantiate(this.panelToday);
        this.currPanel.parent = this.node;
    }

});
